import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    count: 0,
  },
  mutations: {
    INCREMENT(state) {
      state.count += 1;
    },
    DECREMENT(state) {
      state.count -= 1;
    },
    RESET(state) {
      state.count = 0;
    },
  },
  actions: {
    increment({ commit }) {
      commit('INCREMENT');
    },
    decrement({ commit }) {
      commit('DECREMENT');
    },
    reset({ commit }) {
      commit('RESET');
    },
  },
  getters: {
    doubleCount: (state) => state.count * 2,
    isEven: (state) => state.count % 2 === 0,
  },
});
